getUnapprovedProvidersRatings
getUnapprovedProvidersRatings
This method fetches paginated, unapproved provider ratings with optional filtering by business location and/or agent.
-
Initialize Pagination Parameters
- Normalize
pageandlimitvalues to ensure they are at least 1 and 10 respectively. - Calculate
skipvalue for pagination offset based on the current page and limit.
- Normalize
-
Build Database Query
-
Start query on
ratingAppointmentRepotargeting ratings with status"pending". -
Join related entities:
- Customer
- Business Location
- Agent and Agent Type
- Appointment (including EHR appointment data)
-
Apply filters if provided:
- Filter by
businessLocationIdif given. - Filter by
agentIdif given.
- Filter by
-
-
Define Fields to Select
- Select detailed rating fields (overall, provider, staff, clinic ratings, comments, etc.).
- Select customer details (ID, decrypted names, gender identity).
- Select appointment identifiers and start times (both internal and external).
- Select business location details.
- Select agent details including agent type.
-
Execute Query with Pagination
- Apply
.skip(skip)and.take(limit)to paginate results. - Fetch raw data rows.
- Fetch total count of matching records (for pagination metadata).
- Apply
-
Map Raw Data to Structured DTOs
-
For each raw record:
- Construct a rating object including nested customer, appointment, business location, and agent data.
- Decrypt customer first and last names.
-
-
Build and Return Response
-
Compose the response object with:
data: list of mapped rating DTOs.pagination: object containing total records, current page, limit, and total pages.
-